#-DLUA_USE_LINUX   -Wl,-E -ldl -lreadline
#-DLUA_USE_MACOSX  -lreadline
#-DLUA_BUILD_AS_DLL

IF(WIN32)
    ADD_DEFINITIONS(-DLUA_BUILD_AS_DLL)
ELSEIF(UNIX)
    ADD_DEFINITIONS(-DLUA_USE_LINUX)
ELSEIF(APPLE)
    ADD_DEFINITIONS(-DLUA_USE_MACOSX)
ENDIF()

SET(liblua 
    src/lapi.c
    src/lauxlib.c
    src/lbaselib.c
    src/lbitlib.c
    src/lcode.c
    src/lcorolib.c
    src/lctype.c
    src/ldblib.c
    src/ldebug.c
    src/ldo.c
    src/ldump.c
    src/lfunc.c
    src/lgc.c
    src/linit.c
    src/liolib.c
    src/llex.c
    src/lmathlib.c
    src/lmem.c
    src/loadlib.c
    src/lobject.c
    src/lopcodes.c
    src/loslib.c
    src/lparser.c
    src/lstate.c
    src/lstring.c
    src/lstrlib.c
    src/ltable.c
    src/ltablib.c
    src/ltm.c
    #src/lua.c
    #src/luac.c
    src/lundump.c
    src/lutf8lib.c
    src/lvm.c
    src/lzio.c
)


ADD_LIBRARY(liblua SHARED ${liblua})
#SET_TARGET_PROPERTIES(liblua PROPERTIES PREFIX "lib" SUFFIX ".lib")

ADD_EXECUTABLE(lua src/lua.c)
TARGET_LINK_LIBRARIES(lua liblua)

ADD_EXECUTABLE(luac ${liblua} src/luac.c)
TARGET_LINK_LIBRARIES(luac liblua)


IF(APPLE)
    ADD_DEFINITIONS(-DLUA_USE_MACOSX)    
    TARGET_LINK_LIBRARIES(lua readline)
ENDIF()